package com.xr.miniprogram.domain.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xr.miniprogram.domain.*;
import com.xr.miniprogram.tools.StrListTool;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
/**
 * description: 服务日志VO，处理图片
 *
 * @author: wls
 * @date: 2023/10/19 15:10
 * @version:1.0
 */
public class MiniProgramServiceLogVO {
    /**
     * 服务日志id
     */
    @TableId(value = "service_log_id", type = IdType.AUTO)
    private Long serviceLogId;
    /**
     * 打卡图片
     */
    private List<String> clockImg;
    /**
     * 评论id
     */
    private Long miniProgramCommentId;
    /**
     * 服务人员id
     */
    private Long staffId;
    /**
     * 服务完成时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date completeTime;
    /**
     * 服务开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;
    /**
     * 服务状态
     */
    private Long workStatus;
    /**
     * 服务前图片
     */
    private List<String> beforeServiceImg;
    /**
     *服务后图片
     */
    private List<String> afterServiceImg;

    public static MiniProgramServiceLog toMiniProgramServiceLog(MiniProgramServiceLogVO itemVO){
        MiniProgramServiceLog item = new MiniProgramServiceLog();
        item.setServiceLogId(itemVO.getServiceLogId());
        item.setClockImg(StrListTool.listToSingle(itemVO.getClockImg()));
        item.setMiniProgramCommentId(itemVO.getMiniProgramCommentId());
        item.setStaffId(itemVO.getStaffId());
        item.setCompleteTime(itemVO.getCompleteTime());
        item.setStartTime(itemVO.getStartTime());
        item.setWorkStatus(itemVO.getWorkStatus());
        item.setBeforeServiceImg(StrListTool.listToSingle(itemVO.getBeforeServiceImg()));
        item.setAfterServiceImg(StrListTool.listToSingle(itemVO.getAfterServiceImg()));
        return item;
    }


    public static MiniProgramServiceLogVO toMiniProgramServiceLogVO(MiniProgramServiceLog item){
        MiniProgramServiceLogVO itemVO = new MiniProgramServiceLogVO();
        itemVO.setServiceLogId(item.getServiceLogId());
        itemVO.setClockImg(StrListTool.stringToList(item.getClockImg()));
        itemVO.setMiniProgramCommentId(item.getMiniProgramCommentId());
        itemVO.setStaffId(item.getStaffId());
        itemVO.setCompleteTime(item.getCompleteTime());
        itemVO.setStartTime(item.getStartTime());
        itemVO.setWorkStatus(item.getWorkStatus());
        itemVO.setBeforeServiceImg(StrListTool.stringToList(item.getBeforeServiceImg()));
        itemVO.setAfterServiceImg(StrListTool.stringToList(item.getAfterServiceImg()));
        return itemVO;
    }
}
